package com.macro.mall.portal.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.macro.mall.common.api.CommonResult;
import com.macro.mall.portal.domain.BillLading;
import com.macro.mall.portal.domain.ConsultFiles;
import com.macro.mall.portal.domain.vo.PageVo;
import com.macro.mall.portal.service.IBillLadingService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;


@RestController
@RequestMapping("/lading")
@Api(tags = "BillLadingController", description = "提单记录")
public class BillLadingController {

    @Autowired
    private IBillLadingService billLadingService;

    @ApiOperation("提单入口")
    @RequestMapping(value = "/addOne", method = RequestMethod.POST)
    public CommonResult addOne(@RequestBody BillLading billLading) {
        CommonResult commonResult = null;
        try {
            commonResult = billLadingService.addOne(billLading);
        } catch (Exception e) {
            e.printStackTrace();
            return CommonResult.failed("服务器异常");
        }
        return commonResult;
    }

    @ApiOperation("分页查询提单记录")
    @RequestMapping(value = "/queryPage", method = RequestMethod.POST)
    public CommonResult query(@RequestBody PageVo page) {
        IPage<BillLading> filesIPage = null;
        try {
            filesIPage = billLadingService.queryPage(page.getOpenId(),page.getStatus(), page.getPage(), page.getSize());
        } catch (Exception e) {
            e.printStackTrace();
            return CommonResult.failed("服务器异常");
        }
        return CommonResult.success(filesIPage);
    }

    @ApiOperation("分页邀请记录")
    @RequestMapping(value = "/invite", method = RequestMethod.POST)
    public CommonResult invite(@RequestBody PageVo page) {
        Map<String, Object> filesIPage = null;
        try {
            filesIPage = billLadingService.invite(page.getOpenId(),page.getStatus(), page.getPage(), page.getSize());
        } catch (Exception e) {
            e.printStackTrace();
            return CommonResult.failed("服务器异常");
        }
        return CommonResult.success(filesIPage);
    }
}
